package defor.dev.onclickbuttons;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends Activity {

	TextView tvOut;
	Button btnOk;
	Button btnCancel;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);

		// let's find View-elements
		tvOut = (TextView) findViewById(R.id.tvOut);
		btnOk = (Button) findViewById(R.id.btnOk);
		btnCancel = (Button) findViewById(R.id.btnCancel);

		OnClickListener oclBtnOk = new OnClickListener() {

			@Override
			public void onClick(View v) {
				tvOut.setText("Ok button clicked");

			}
		};
		btnOk.setOnClickListener(oclBtnOk);

		OnClickListener oclBtnCancel = new OnClickListener() {

			@Override
			public void onClick(View v) {
				tvOut.setText("Cancel button clicked");

			}
		};
		btnCancel.setOnClickListener(oclBtnCancel);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

}
